#include <iostream>
#include <stdlib.h>
#ifdef _WIN32
#include "windows.h"
#endif

using namespace std;

int main(int argc, char * argv[]) {

  const string DESC = "Search terms with Google";
  const int SUBTYPE = 2;
  const int AUX = 0;
  
  if (argc < 1) {
    cout<<"Error: Must have arguments";
    return 1;
  } else if (string(argv[1]) == "-h") {
    cout<<DESC;
  } else if (string(argv[1]) == "-t") {
    cout<<SUBTYPE;
  } else if (string(argv[1]) == "-x") {
    cout<<AUX;
  } else {
    #ifdef _WIN32
    string cmd = "\"http://www.google.com/search?q=" + string(argv[1]) + "\"";
    ShellExecute(NULL, "open", cmd.c_str(), NULL, NULL, SW_SHOWNORMAL);
    #else
    string cmd = "open \"http://www.google.com/search?q=" + string(argv[1]) + "\"";
    system(cmd.c_str());
    #endif
  }
  
  return 0;
}
